package cn.liutao.order.api;

import cn.liutao.common.utils.AuthUtils;
import cn.liutao.common.utils.ServletUtils;
import cn.liutao.order.entity.param.OrderQueryParam;
import cn.liutao.order.entity.vo.OrderVo;
import cn.liutao.order.service.OrderService;
import com.mybatisflex.core.paginate.Page;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: liutao
 * @description: 用于管理端获取所有用户订单列表
 * @date: 2023/11/27 22:07
 */
@WebServlet("/order/list/all")
public class OrderListServlet extends HttpServlet {

    private OrderService orderService;

    @Override
    public void init() throws ServletException {
        orderService = OrderService.getInstance();
    }

    /**
     * 查询订单
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        AuthUtils.isAdmin();
        OrderQueryParam queryParam = ServletUtils.getQueryParam(req, OrderQueryParam.class);
        Page<OrderVo> page  = orderService.selectList(queryParam);
        ServletUtils.ok(resp,page);
    }
}
